package models;

import java.util.List;

import siena.Generator;
import siena.Id;
import siena.Model;
import siena.Table;

@Table("category_node")
public class CategoryNode extends Model{

	@Id(Generator.AUTO_INCREMENT)
	public Long id;
	
	public long parentId;
	public String type;
	public String title;
	public int left;
	public int right;
	public int position;
	
	public static CategoryNode find(long id) {
		return Model.getByKey(CategoryNode.class, id);
	}
	
	public static List<CategoryNode> load(long id) {
		return Model.all(CategoryNode.class).filter("parentId", id).order("position").fetch();
	}
}
